/*
 *  CEMenuItemSpriteText.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_MenuItemSpriteText_h__
#define __CE_MenuItemSpriteText_h__

#include "cocos2dx_extentions/controls/CEMenuItemSprite.h"
#include "cocos2dx_extentions/labels/CELabelMBFontWrapperScissored.h"

namespace cocosext {

/////////////////////////////////////////////////////
//
/** CEMenuItemSpriteText 
* Menu which works closly with CEScrollView, which is its ancestor
*/
/////////////////////////////////////////////////////

struct CETextDescription
{
	CELabelBMFont* pNormalText;
    CELabelBMFont* pSelectedText;
    CELabelBMFont* pDisabledText;

	ECETextAllign textAllign;
	
	float marginBottom;
	float marginTop;
	float marginLeft;
	float marginRight;

public:
	CETextDescription()
		: pNormalText(NULL)
		, pSelectedText(NULL)
		, pDisabledText(NULL)
		, textAllign(eCE_TA_left)
		, marginBottom(0.f)
		, marginTop(0.f)
		, marginLeft(0.f)
		, marginRight(0.f) {;} 
};

class CEMenuItemSpriteText : public CEMenuItemSprite, public CELabelProtocol
{
	CELabelMBFontWrapperScissored* _pNormalText;
    CELabelMBFontWrapperScissored* _pSelectedText;
    CELabelMBFontWrapperScissored* _pDisabledText;

protected:
	CEMenuItemSpriteText(): _pNormalText(NULL), _pSelectedText(NULL), _pDisabledText(NULL) {;}

public:
    virtual ~CEMenuItemSpriteText() {;}

    /** creates a menu item with a normal,selected  and disabled image with target/selector */
    static CEMenuItemSpriteText* itemFromNormalSprite(const CETextDescription& textInfo, cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCNode* disabledSprite = NULL, cocos2d::CCObject* target = NULL, cocos2d::SEL_MenuHandler selector = NULL);

public:
    /** initializes a menu item with a normal, selected  and disabled image with target/selector */
    bool initFromNormalSprite(const CETextDescription& textInfo, cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler selector);

public:
// CELabelProtocol interface
	void setString(const wchar_t *str);
	const wchar_t* getString(void) const { return _pNormalText->getString(); }

// Cocos2d interface
	virtual void setRotation(float fRotation);

}; //CEMenuItemSpriteText


}; // end namespace cocosext

#endif // __CE_MenuItemSpriteText_h__
